package com.tencent.compose.sample.mainpage.sectionItem

import kotlinx.cinterop.ExperimentalForeignApi
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import sanTest.HeapBufferOverflow
import sanTest.StackBufferOverflow
import sanTest.StackBufferUnderflow
import sanTest.HeapUseAfterFree
import sanTest.StackUseAfterScope
import sanTest.AttempFreeNonAllocatedMem
import sanTest.DoubleFree
import sanTest.HeapBufferUnderflow

@Composable
@OptIn(ExperimentalForeignApi::class)
internal actual fun PlatformInteropButtons() {
    Button(onClick = { HeapBufferOverflow() }) {
        Text("heap-buffer-overflow C++")
    }

    Button(onClick = { StackBufferOverflow() }) {
        Text("stack-buffer-overflow C++")
    }

    Button(onClick = { StackBufferUnderflow() }) {
        Text("stack-buffer-underflow C++")
    }

    Button(onClick = { HeapUseAfterFree() }) {
        Text("heap-use-after-free C++")
    }

    Button(onClick = { StackUseAfterScope() }) {
        Text("stack-use-after-scope C++")
    }

    Button(onClick = { AttempFreeNonAllocatedMem() }) {
        Text("attempt-free-nonallocated-memory C++")
    }

    Button(onClick = { DoubleFree() }) {
        Text("double-free C++")
    }

    // ===heap-buffer-overflow===
    Button(onClick = { HeapBufferUnderflow() }) {
        Text("heap-buffer-underflow C++")
    }
}
